﻿using FlashGameSite.Manager;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace FlashGameSite
{
    public partial class FormContact : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected void btnContact_Click(object sender, EventArgs e)
        {
            using (FlashGamesDataContext dataContext = new FlashGamesDataContext())
            {
                ContactForm contact = new ContactForm()
                {
                    EmailID = txtEmailID.Text,
                    Message = txtMessage.Text,
                    Name = txtName.Text,
                    CreatedDate = DateTime.Now
                };

                dataContext.ContactForms.InsertOnSubmit(contact);
                dataContext.SubmitChanges();
                Common.SendMail(txtEmailID.Text, "Thanks for contacting us", "");
                txtEmailID.Text = "";
                txtMessage.Text = "";
                txtName.Text = "";

                ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "alert('Thanks for contacting us! We will reply you soon.')", true);
            }
        }
    }
}